package com.welink.web.resource;

import com.alibaba.fastjson.JSON;
import com.welink.biz.common.Model.UserInfo;
import com.welink.biz.common.Model.WelinkVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daniel on 15-3-16.
 */
@Controller
public class GreetingController {

    @RequestMapping({"/m/greeting.json","/h/1.0/greeting.json"})
    @ResponseBody
    public String greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
        UserInfo model = new UserInfo();
        model.setUserId(100);
        model.setUserName("王坤");
        WelinkVO welinkVO = new WelinkVO();
        welinkVO.setStatus(1);
        Map<String, Object> resultMap = new HashMap<>();
        UserInfo user = new UserInfo();
        user.setUserId(100);
        user.setUserName("yonder");
        resultMap.put("user", user);
        resultMap.put("point", 1001);
        welinkVO.setResult(resultMap);
        return JSON.toJSONString(welinkVO);
    }

    @RequestMapping({"/m/fetch.json","/h/1.0/fetch.json"})
    @ResponseBody
    public String fetch(@RequestParam(value = "name", defaultValue = "World") String name) {
        UserInfo model = new UserInfo();
        model.setUserId(100);
        model.setUserName("fetch");
        WelinkVO welinkVO = new WelinkVO();
        welinkVO.setStatus(1);
        Map<String, Object> resultMap = new HashMap<>();
        UserInfo user = new UserInfo();
        user.setUserId(100);
        user.setUserName("fetch");
        resultMap.put("fetch", user);
        resultMap.put("point", 1001);
        welinkVO.setResult(resultMap);
        return JSON.toJSONString(welinkVO);
    }
}